package com.king.designpatterns.行为模式.中介者模式;

/**
 * 抽象对象 - 人的抽象类
 *
 * @author king
 * @date 2021-06-10 17:56
 */
public class Person {
    /**
     * 姓名
     */
    String name;
    /**
     * 年龄
     */
    int age;
    /**
     * 性别
     */
    Sex sex;
    /**
     * 要求对象的年龄
     */
    int requestAge;
    /**
     * 婚姻中介
     */
    MarriageAgency agency;

    public Person(String name, int age, Sex sex, int requestAge, MarriageAgency agency) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.requestAge = requestAge;
        this.agency = agency;
        agency.register(this);
    }

    /**
     * 寻找对象
     */
    public void findPartner(){
        agency.pair(this);
    }
}
